import java.util.Scanner;

public class Day_36_1_RationalArithmetic {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        String str2 = sc.next();
        String [] str3 =str1.split("/");
        String [] str4 =str2.split("/");
        long a1 = Integer.valueOf(str3[0]);
        long a2 = Integer.valueOf(str3[1]);
        long b1 = Integer.valueOf(str4[0]);
        long b2 = Integer.valueOf(str4[1]);
        System.out.println(addition(a1,a2,b1,b2));
        System.out.println(Subtraction(a1,a2,b1,b2));
        System.out.println(multiplication(a1,a2,b1,b2));
        System.out.println(division(a1,a2,b1,b2));
    }
    //通分适用于加减法
    private static long [] PassPoints(long a1,long a2 ,long b1 ,long b2) {
        long [] arr = new long[4];
        arr[0] = a1*b2;
        arr[1] = a2*b2;
        arr[2] = b1*a2;
        arr[3] = a2*b2;
        return arr;
    }
    //约分
    private static String Reduce(long [] arr) {
        String w3 ;
        long x;
        long y;
        long zhengshu = 0;
        long z = 0;
        if (arr[1]==0){
            return  w3 = "Inf";
        }
        if (arr[0]==arr[1]){
            w3 = String.valueOf(1);
        } else if (arr[0]==0){
            w3 = String.valueOf(0);
        } else {
            //先找公约数；
            x = Math.abs(arr[0]);
            y = arr[1];
            z = x < y ? x : y;
            while (z > 1) {
                if (x % z == 0 && y % z == 0) {
                    x = x / z;
                    y = y / z;
                }
                z--;
            }
            if (arr[0] > 0){
                arr[0] = x;
                arr[1] = y;
                if (arr[0] > arr[1]) {
                    zhengshu = arr[0] / arr[1];
                    arr[0] = arr[0] % arr[1];
                    if (arr[0] == 0) {
                        w3 = String.valueOf(zhengshu);
                    } else {
                        w3 = String.valueOf(zhengshu) + " " + String.valueOf(arr[0]) + "/" + String.valueOf(arr[1]);
                    }
                } else {
                    w3 = String.valueOf(arr[0]) + "/" + String.valueOf(arr[1]);
                }
            }else {
                arr[0] = x;
                arr[1] = y;
                if (arr[0] > arr[1]) {
                    zhengshu = arr[0] / arr[1];
                    arr[0] = arr[0] % arr[1];
                    if (arr[0] == 0) {
                        w3 ="(" + String.valueOf(-zhengshu)+ ")";
                    } else {
                        w3 = "(" +String.valueOf(-zhengshu) + " " + String.valueOf(arr[0]) + "/" + String.valueOf(arr[1])+ ")";
                    }
                } else {
                    w3 ="(" + String.valueOf(-arr[0]) + "/" + String.valueOf(arr[1])+ ")";
                }
            }
        }
        return w3;
    }
    //除法处理
    private static String division(long a1,long a2 ,long b1 ,long b2) {
        long yinshi1[] = new long []{a1,a2};
        long yinshi2[] = new long []{b1,b2};
        String str1 = Reduce(yinshi1);
        String str2 = Reduce(yinshi2);
        long [] arr2 = new long[2];
        arr2[0] = a1*b2;
        arr2[1] = a2*b1;
        if (arr2[1]<0){
            arr2[0] = -a1*b2;
            arr2[1] = -a2*b1;
        }
        String str3 = Reduce(arr2);
        String str4 = str1+ " " + "/" + " " + str2 +" "+ "=" +" "+ str3 ;
        return str4;
    }
    //    //乘法处理
    private static String multiplication(long a1,long a2 ,long b1 ,long b2) {
        long yinshi1[] = new long []{a1,a2};
        long yinshi2[] = new long []{b1,b2};
        String str1 = Reduce(yinshi1);
        String str2 = Reduce(yinshi2);
        long [] arr2 = new long[2];
        arr2[0] = a1*b1;
        arr2[1] = a2*b2;
        String str3 = Reduce(arr2);
        String str4 = str1+ " " + "*" + " " + str2 +" "+ "=" +" "+ str3 ;
        return str4;
    }
    //减法处理
    private static String Subtraction(long a1,long a2 ,long b1 ,long b2) {
        long yinshi1[] = new long []{a1,a2};
        long yinshi2[] = new long []{b1,b2};
        String str1 = Reduce(yinshi1);
        String str2 = Reduce(yinshi2);
        long [] arr1 = PassPoints(a1,a2,b1,b2);
        long [] arr2 = new long[2];
        arr2[0] = arr1[0]-arr1[2];
        arr2[1] = arr1[1];
        String str3 = Reduce(arr2);
        String str4 = str1+ " " + "-" + " " + str2 +" "+ "=" +" "+ str3 ;
        return str4;
    }
    //加法处理
    private static String addition(long a1,long a2 ,long b1 ,long b2 ) {
        long yinshi1[] = new long []{a1,a2};
        long yinshi2[] = new long []{b1,b2};
        String str1 = Reduce(yinshi1);
        String str2 = Reduce(yinshi2);
        long [] arr1 = PassPoints(a1,a2,b1,b2);
        long [] arr2 = new long[2];
        arr2[0] = arr1[0]+arr1[2];
        arr2[1] = arr1[1];
        String str3 = Reduce(arr2);
        String str4 = str1+ " " + "+" + " " + str2 +" "+ "=" +" "+ str3 ;
        return str4;
    }

}
